/-app ...
/-app/files
/-app/layout
/-app/tests
Application.ts
functions.ts
/-boot
/-docs
/-features
/-imports
/-koBindings
/-storage
/-tests
/-typings
base.css
readme.md
stringUtils.ts
teapo.html
try.html
try.js
1
module teapo.app {
2
 
3
  export class Application {
4
 
5
    tests: tests.TestPage = null;
6
 
7
    scrollLeft = ko.observable(1);
8
    scrollTop = ko.observable(2);
9
 
10
    constructor(private _body = document.body) {
11
 
12
      this._startBoot();
13
    }
14
 
15
    debugg() {
16
      this.scrollLeft(this.scrollLeft() + 1);
17
      this.scrollTop(this.scrollTop() + 2);
18
    }
19
 
20
    private _startBoot() {
21
      earlyElement('Loading test list...');
22
 
23
      setTimeout(() => {
24
        this.tests = new tests.TestPage();
25
 
26
        setTimeout(() => {
27
          earlyElement('Rendering...');
28
          this._completeBoot();
29
        }, 2000);
30
      }, 10);
31
    }
32
 
33
    private _completeBoot() {
34
      try {
35
        var tmpHost = document.createElement('div');
36
        ko.renderTemplate('Application', this, null, tmpHost);
37
        var child: HTMLElement;
38
        for (var i = 0; i < tmpHost.children.length; i++) { 
39
          if (tmpHost.children.item(i).tagName) {
40
            child = <any>tmpHost.children.item(i);
41
            document.body.appendChild(child);
42
            break;
43
          }
44
        }
45
 
46
        var startAnimation = Date.now();
47
        var endAnimation = startAnimation + 400;
48
 
49
        var containerWidth = child.offsetWidth;
50
        var pageWidth = earlyElement.background.offsetWidth;
51
        var continueAnimation = () => {
52
          try {
53
            var now = Date.now();
54
            if (now >= endAnimation) {
55
              earlyElement.close();
56
              child.style.left = '0px';
57
              return;
58
            }
59
 
60
            var ratio = (now - startAnimation) / (endAnimation - startAnimation);
61
            child.style.left = (-containerWidth + ratio * containerWidth) + 'px';
62
            earlyElement.background.style.left = (ratio * containerWidth) + 'px';
63
 
64
 
65
 
66
            if (typeof requestAnimationFrame === 'function')
67
              requestAnimationFrame(continueAnimation)
68
        else
69
              setTimeout(continueAnimation, 1);
70
          }
71
          catch (animationError) { 
72
            alert('Application._completeBoot:continueAnimation ' + animationError.message + '\n' + animationError.stack);
73
          }
74
        }